#include "EdibleFish.h"
#include "texturelibrary.h"
#include <iostream>
#include "PlayerController.h"

void EdibleFish :: Update(float deltaT)
{
	ScrollingObject::Update(deltaT);
	if (isAlive)
	{
		pos = sf::Vector2f(pos.x, startHeight + (bobHeight * sin((timer.getElapsedTime().asSeconds() + bobTimerOffset) * bobSpeed)));
	}
	else
	{
	
	}
}

void EdibleFish::CollidedWith(Object* collided)
{
	if (collided->name == "Player" && isAlive)
	{
		
		PlayerController* p = (PlayerController*)collided;
		p->AteFish(scale);
		isAlive = false;
		isPhysical = true;
		name = "Skeleton";

		sf::Texture *myNewTexture = NULL;
		myNewTexture = TT::TextureLibrary[skeletonFileName];
		if (myNewTexture != NULL)
		{
			GameStateManager::DecreaseNumOfFish();
			mySprite.setTexture(*myNewTexture);
		}	
		else
			std::cout << "ERROR: could not load sprite with Skeleton Image" << std::endl;
	}
}